//index.js

Page({
  data: {
    startNum:'',
    endNum:'',
    result:''
  },
  start:function(e){
    this.setData({
      startNum:e.detail.value
    })
  },
  end:function(e){
    this.setData({
      endNum:e.detail.value
    })
  },
  sumSubmit:function(){
    if(this.data.startNum==""||this.data.endNum==""){
      this.setData({
        result:"计算有误！输入数据不完整"
      })
      return;
    }
    var re=0;
    if(this.data.endNum*1<this.data.startNum*1){
      var a=this.data.startNum;
      this.data.startNum=this.data.endNum;
      this.data.endNum=a;
    }
    for(var i=this.data.startNum*1;i<=this.data.endNum*1;i++){
      re=re+i;
    }
    this.setData({
      result:re
    })
  }
})
